﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAO;
using DTO;

namespace DAO
{
    public class DAO_NguoiDung
    {
        private DataServices data = new DataServices();

        public DataTable Login(string username, string password)
        {
            DataTable dt = null;
            try
            {
                string sql = "SELECT * FROM " + DTO_NguoiDung.TB_NAME
                            + " WHERE " + DTO_NguoiDung.TENDANGNHAP + " = @" + DTO_NguoiDung.TENDANGNHAP
                            + " AND " + DTO_NguoiDung.MATKHAU + " = @" + DTO_NguoiDung.MATKHAU;
                
                SqlParameter p1 = new SqlParameter(DTO_NguoiDung.TENDANGNHAP, username);
                SqlParameter p2 = new SqlParameter(DTO_NguoiDung.MATKHAU, password);
                dt = data.executeGetDataTable(sql, p1, p2);
            }
            catch (Exception ex)
            {
                throw new Exception("Lỗi thực hiện truy vấn csdl khi đăng nhập",ex);
            }

            return dt;
        } 
    }
}
